<template>
  <button
    type="button"
    class="btn-prev"
    :disabled="internalDisabled"
    @click="$emit('click')"
  >
    <span v-if="prevText">{{ prevText }}</span>
    <h-icon class="icon" v-else :icon="prevIcon!"></h-icon>
  </button>
</template>

<script setup lang="ts">
import { computed } from "vue";
import type { PrevProps } from "./type";
import HIcon from "@/components/Icon/HIcon.vue";

const {
  currentPage = 1,
  disabled,
  prevText,
  prevIcon = ["fas", "arrow-left"],
} = defineProps<PrevProps>();

defineEmits(["click"]);

const internalDisabled = computed(() => disabled || currentPage <= 1);
</script>

<style scoped>
@import url(./style.css);
</style>
